/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.activity.editpart;

import org.eclipse.uml2.uml.CallOperationAction;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.ElementImport;

import com.cea.papyrus.core.editor.ModelManager;
import com.cea.papyrus.core.utils.Debug;
import com.cea.papyrus.diagraminterchange2.di2.GraphNode;
import com.cea.papyrus.diagraminterchange2.di2.Uml1SemanticModelBridge;

/**
 * Controller of a CallOperationAction
 *
 * @author Gilles Cannenterre
 * @since 29 mars 07
 */
public class CallOperationActionEditPart extends CallActionEditPart {

	public CallOperationActionEditPart(GraphNode graphNode,
			ModelManager modelManager) {
		super(graphNode, modelManager);
	}

	/* (non-Javadoc)
	 * @see com.cea.papyrus.core.common.editpart.GraphNodeWithSemanticEditPart#getUmlElement()
	 */
	@Override
	public CallOperationAction getUmlElement() {
		Element e = ((Uml1SemanticModelBridge)getGraphNode().getSemanticModel()).getElement();
		// Case of element import
		if(e instanceof ElementImport){
			return (CallOperationAction)((ElementImport) e).getImportedElement();
		}
		// This is a simple CallOperationAction
		return (CallOperationAction)e;
	}

	protected void refreshVisuals() {
		Debug.debug(this, "refreshVisuals()", channel);
		if (getUmlElement().getOperation()!=null &&getUmlElement().getTarget()!=null){
			this.prefix=getUmlElement().getTarget().getName();
			this.prefix+="."+getUmlElement().getOperation().getLabel();}
		else{
			this.prefix="";
		}
		super.refreshVisuals();
	}
}
